Skip to content

feat: update DevContext and LSP to support composable schemas#2965

Open
tstirrat15 wants to merge 2 commits intomainfrom
tstirrat/file-aware-development-system
Open

feat: update DevContext and LSP to support composable schemas#2965
tstirrat15 wants to merge 2 commits intomainfrom
tstirrat/file-aware-development-system

Conversation

@tstirrat15
Copy link
Contributor

@tstirrat15 tstirrat15 commented Mar 10, 2026

Description

Filesystem-aware development system — The DevContext and schema compilation now accept a filesystem
(fs.FS), enabling validation of schemas that use import syntax (composable schemas).

Key changes:

  1. pkg/development/ — devcontext.go and schema.go updated to thread an fs.FS through schema
    compilation. The position mapper (schema_position_mapper.go) was reworked significantly to
    handle multi-file schemas correctly, with new tests.
  2. pkg/schemadsl/compiler/ — The importer and position mapper now work with filesystem-backed
    sources. development.go gained helpers for filesystem-aware compilation. The translator
    tracks source file information more precisely.
  3. LSP (internal/lsp/) — New overlay filesystem (overlay.go) lets the LSP validate open/unsaved files
    by layering in-memory content over the real filesystem. Handlers updated to support
    textDocument/definition (go-to-definition) and fix requestDiagnostics. Substantial new tests.
  4. Minor fixes — e.g. prevent panics

Testing

you can test this by bringing it over to VSCode and trying it out with schemas of your own. you have to

On spicedb repo:  gh pr checkout 2965 && mage build:binary
On vscode repo : gh pr checkout 51
edit line 95 on package.json to point to the binary you created in step 1
hit F5 to run the extension

if you want to test in zed:

On zed repo: gh pr checkout 635 && mage build:binary
you can now do ./zed validate ....

@github-actions github-actions bot added the area/schema Affects the Schema Language label Mar 10, 2026
@tstirrat15 tstirrat15 force-pushed the tstirrat/file-aware-development-system branch from cffe476 to e20db9f Compare March 10, 2026 20:38
@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 76.49007% with 71 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.80%. Comparing base (e49cc12) to head (dae057f).

Files with missing lines Patch % Lines
internal/lsp/handlers.go 70.15% 15 Missing and 5 partials ⚠️
pkg/schemadsl/compiler/development.go 70.22% 9 Missing and 5 partials ⚠️
pkg/development/devcontext.go 33.34% 12 Missing ⚠️
pkg/development/schema_position_mapper.go 90.33% 4 Missing and 2 partials ⚠️
internal/lsp/overlay.go 82.15% 5 Missing ⚠️
pkg/caveats/parameters.go 0.00% 2 Missing and 1 partial ⚠️
pkg/development/warnings.go 0.00% 2 Missing and 1 partial ⚠️
pkg/schemadsl/compiler/translator.go 70.00% 2 Missing and 1 partial ⚠️
pkg/schemadsl/compiler/importer.go 84.62% 2 Missing ⚠️
pkg/schemadsl/compiler/positionmapper.go 87.50% 2 Missing ⚠️
... and 1 more

❌ Your project check has failed because the head coverage (74.80%) is below the target coverage (75.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2965      +/-   ##
==========================================
- Coverage   74.82%   74.80%   -0.02%     
==========================================
  Files         497      498       +1     
  Lines       60656    60868     +212     
==========================================
+ Hits        45382    45526     +144     
- Misses      12115    12166      +51     
- Partials     3159     3176      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@miparnisari miparnisari force-pushed the tstirrat/file-aware-development-system branch 2 times, most recently from 3998ee0 to e20db9f Compare March 13, 2026 20:57
@github-actions github-actions bot added the area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) label Mar 13, 2026
@miparnisari miparnisari force-pushed the tstirrat/file-aware-development-system branch 4 times, most recently from 2fbc435 to 9ef3b65 Compare March 14, 2026 03:05
@miparnisari miparnisari force-pushed the tstirrat/file-aware-development-system branch from 9ef3b65 to 5dcc950 Compare March 16, 2026 17:37
@miparnisari miparnisari changed the title chore: make development system filesystem-aware feat: update DevContext and LSP to support composable schemas Mar 16, 2026
@miparnisari miparnisari force-pushed the tstirrat/file-aware-development-system branch 10 times, most recently from 12bc73d to a1130f6 Compare March 17, 2026 02:39
@miparnisari miparnisari marked this pull request as ready for review March 17, 2026 02:41
@miparnisari miparnisari requested a review from a team as a code owner March 17, 2026 02:41
@miparnisari miparnisari force-pushed the tstirrat/file-aware-development-system branch 2 times, most recently from 254aa41 to 10d5e84 Compare March 17, 2026 06:22
return hoverContents, nil
}

func (s *Server) textDocDefinition(_ context.Context, r *jsonrpc2.Request) (*lsp.Location, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this is what gets called in Vs Code when you click F12/Go to Definition


// Get errors.
for _, devErr := range devErrs.GetInputErrors() {
if !slices.Contains(devErr.Path, string(uri)) {
Copy link
Contributor

@miparnisari miparnisari Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this code gets called in VSCode when you save a file.

devErrs contains errors from ALL files,.

However, computeDiagnostics is only computing errors for uri.

}
if derr != nil {
return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInternalError, Message: derr.String()}
return nil, errors.New(derr.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI otherwise this get shown in the error console but not to the user


// ParameterTypeString returns the string form of the type reference.
func ParameterTypeString(typeRef *core.CaveatTypeReference) string {
if typeRef == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI prevents a panic in line 73. Can move to different PR if so desired

Context: errWithSource.SourceCodeString,
Line: lineNumber,
Column: columnPosition,
Path: []string{path},
Copy link
Contributor

@miparnisari miparnisari Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI zed uses this to show the correct content from the file that has the error

@miparnisari miparnisari force-pushed the tstirrat/file-aware-development-system branch 2 times, most recently from 4eeb6c9 to fe72591 Compare March 17, 2026 06:41
…d support for textDocument/definition, support composable schemas). fix position mapper
@miparnisari miparnisari force-pushed the tstirrat/file-aware-development-system branch from fe72591 to dae057f Compare March 17, 2026 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/schema Affects the Schema Language area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) Skip-Changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants